package com.example.c5c6;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.FilterConfig;
import java.io.IOException;
import java.io.PrintWriter;

public class ServletConfigTest extends HttpServlet {
    private FilterConfig config;
    @Override
    public  void init() throws ServletException {
        super.init();
    }
    public ServletConfigTest() {
        super();
    }
    @Override
    public void destroy() {
        super.destroy();
    }
  
    protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
        String charset = this.config.getInitParameter("charset");
        response.setCharacterEncoding(charset);
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>ServletConfig</title></head>");
        out.println("<body>");
        out.println("获取InitParamServlet的初始化参数\"encoding\"的字符串值:"+"charset");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
        doPost(request,response);
    }
}
